When the Process Manager launches your application, it creates and runs a special thread, called the main thread or application thread. The main function is the entry point to this thread and to the application. The main thread has some characteristics that distinguish it from other threads. It is the only thread that has a preallocated stack--the stacks for threads that your application creates reside in separate areas of the heap. The main thread is the only thread from which you properly can extend the application heap. Therefore you should call MaxApplZone from the main thread immediately after your application launches, or at least before any other threads run.
Another characteristic of the main thread is that the Thread Manager assumes the main thread handles event processing. Therefore, whenever an operating-system event occurs, the Thread Manager schedules the main thread at the next scheduling opportunity, no matter where the main thread happens to be in the scheduling queue.
Note
After an operating-system event, the Thread Manager schedules the main thread at the next opportunity unless you have specified a particular thread to run. In other words, if you call a function such as YieldToAnyThread to cause the rescheduling, the Thread Manager runs the main thread. If, however, you call a function such as YieldToThread and specify a particular thread to run, the Thread Manager schedules that thread rather than the main thread even after the occurrence of an operating-system event.
To guarantee responsiveness to users, you should put all your event handling in the main thread. For the same reason, it is highly recommended that you never put the main thread in the stopped state.